home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Milan_1991 / Devcon91.2 / Network / Socket / include / sys / socket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-01  |  4.9 KB  |  161 lines

  1. #ifndef SYS_SOCKET_H
  2. #define SYS_SOCKET_H
  3.  
  4. /*
  5.  * Copyright (c) 1982, 1985, 1986 Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms are permitted
  9.  * provided that the above copyright notice and this paragraph are
  10.  * duplicated in all such forms and that any documentation,
  11.  * advertising materials, and other materials related to such
  12.  * distribution and use acknowledge that the software was developed
  13.  * by the University of California, Berkeley.  The name of the
  14.  * University may not be used to endorse or promote products derived
  15.  * from this software without specific prior written permission.
  16.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  17.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  18.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19.  *
  20.  *    @(#)socket.h    7.3 (Berkeley) 6/27/88
  21.  */
  22.  
  23. /*
  24.  * Definitions related to sockets: types, address families, options.
  25.  */
  26.  
  27. /*
  28.  * Types
  29.  */
  30. #define    SOCK_STREAM    1        /* stream socket */
  31. #define    SOCK_DGRAM    2        /* datagram socket */
  32. #define    SOCK_RAW    3        /* raw-protocol interface */
  33. #define    SOCK_RDM    4        /* reliably-delivered message */
  34. #define    SOCK_SEQPACKET    5        /* sequenced packet stream */
  35.  
  36. /*
  37.  * Option flags per-socket.
  38.  */
  39. #define    SO_DEBUG    0x0001        /* turn on debugging info recording */
  40. #define    SO_ACCEPTCONN    0x0002        /* socket has had listen() */
  41. #define    SO_REUSEADDR    0x0004        /* allow local address reuse */
  42. #define    SO_KEEPALIVE    0x0008        /* keep connections alive */
  43. #define    SO_DONTROUTE    0x0010        /* just use interface addresses */
  44. #define    SO_BROADCAST    0x0020        /* permit sending of broadcast msgs */
  45. #define    SO_USELOOPBACK    0x0040        /* bypass hardware when possible */
  46. #define    SO_LINGER    0x0080        /* linger on close if data present */
  47. #define    SO_OOBINLINE    0x0100        /* leave received OOB data in line */
  48.  
  49. /*
  50.  * Additional options, not kept in so_options.
  51.  */
  52. #define SO_SNDBUF    0x1001        /* send buffer size */
  53. #define SO_RCVBUF    0x1002        /* receive buffer size */
  54. #define SO_SNDLOWAT    0x1003        /* send low-water mark */
  55. #define SO_RCVLOWAT    0x1004        /* receive low-water mark */
  56. #define SO_SNDTIMEO    0x1005        /* send timeout */
  57. #define SO_RCVTIMEO    0x1006        /* receive timeout */
  58. #define    SO_ERROR    0x1007        /* get error status and clear */
  59. #define    SO_TYPE        0x1008        /* get socket type */
  60.  
  61. /*
  62.  * Structure used for manipulating linger option.
  63.  */
  64. struct    linger {
  65.     int    l_onoff;        /* option on/off */
  66.     int    l_linger;        /* linger time */
  67. };
  68.  
  69. /*
  70.  * Level number for (get/set)sockopt() to apply to socket itself.
  71.  */
  72. #define    SOL_SOCKET    -1        /* options for socket level */
  73.  
  74. /*
  75.  * Address families.
  76.  */
  77. #define    AF_UNSPEC    0        /* unspecified */
  78. #define    AF_UNIX        1        /* local to host (pipes, portals) */
  79. #define    AF_INET        2        /* internetwork: UDP, TCP, etc. */
  80. #define    AF_IMPLINK    3        /* arpanet imp addresses */
  81. #define    AF_PUP        4        /* pup protocols: e.g. BSP */
  82. #define    AF_CHAOS    5        /* mit CHAOS protocols */
  83. #define    AF_NS        6        /* XEROX NS protocols */
  84. #define    AF_NBS        7        /* nbs protocols */
  85. #define    AF_ECMA        8        /* european computer manufacturers */
  86. #define    AF_DATAKIT    9        /* datakit protocols */
  87. #define    AF_CCITT    10        /* CCITT protocols, X.25 etc */
  88. #define    AF_SNA        11        /* IBM SNA */
  89. #define AF_DECnet    12        /* DECnet */
  90. #define AF_DLI        13        /* Direct data link interface */
  91. #define AF_LAT        14        /* LAT */
  92. #define    AF_HYLINK    15        /* NSC Hyperchannel */
  93. #define    AF_APPLETALK    16        /* Apple Talk */
  94.  
  95. #define    AF_MAX        17
  96.  
  97. /*
  98.  * Structure used by kernel to store most
  99.  * addresses.
  100.  */
  101. struct sockaddr {
  102.     u_short    sa_family;        /* address family */
  103.     char    sa_data[14];        /* up to 14 bytes of direct address */
  104. };
  105.  
  106. /*
  107.  * Structure used by kernel to pass protocol
  108.  * information in raw sockets.
  109.  */
  110. struct sockproto {
  111.     u_short    sp_family;        /* address family */
  112.     u_short    sp_protocol;        /* protocol */
  113. };
  114.  
  115. /*
  116.  * Protocol families, same as address families for now.
  117.  */
  118. #define    PF_UNSPEC    AF_UNSPEC
  119. #define    PF_UNIX        AF_UNIX
  120. #define    PF_INET        AF_INET
  121. #define    PF_IMPLINK    AF_IMPLINK
  122. #define    PF_PUP        AF_PUP
  123. #define    PF_CHAOS    AF_CHAOS
  124. #define    PF_NS        AF_NS
  125. #define    PF_NBS        AF_NBS
  126. #define    PF_ECMA        AF_ECMA
  127. #define    PF_DATAKIT    AF_DATAKIT
  128. #define    PF_CCITT    AF_CCITT
  129. #define    PF_SNA        AF_SNA
  130. #define PF_DECnet    AF_DECnet
  131. #define PF_DLI        AF_DLI
  132. #define PF_LAT        AF_LAT
  133. #define    PF_HYLINK    AF_HYLINK
  134. #define    PF_APPLETALK    AF_APPLETALK
  135.  
  136. #define    PF_MAX        AF_MAX
  137.  
  138. /*
  139.  * Maximum queue length specifiable by listen.
  140.  */
  141. #define    SOMAXCONN    5
  142.  
  143. /*
  144.  * Message header for recvmsg and sendmsg calls.
  145.  */
  146. struct msghdr {
  147.     caddr_t    msg_name;        /* optional address */
  148.     int    msg_namelen;        /* size of address */
  149.     struct    iovec *msg_iov;        /* scatter/gather array */
  150.     int    msg_iovlen;        /* # elements in msg_iov */
  151.     caddr_t    msg_accrights;        /* access rights sent/received */
  152.     int    msg_accrightslen;
  153. };
  154.  
  155. #define    MSG_OOB        0x1        /* process out-of-band data */
  156. #define    MSG_PEEK    0x2        /* peek at incoming message */
  157. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  158.  
  159. #define    MSG_MAXIOVLEN    16
  160.  
  161. #endif /* SYS_SOCKET_H */